{% load tagging_tags %}

{% if client_list %}
<table width="100%">
  <tr>
    <th>Name</th>
    <th>Roles</th>
    <th>Email</th>
    <th>Office Phone</th>
    <th>Tags</th>
  </tr>
  {% for client in client_list %}
  <tr>
    <td>
      <a href="{% url crm_client_detail object_id=client.id %}">{{ client.user.first_name }} {{ client.user.last_name }}</a>
    </td>
    <td>
      <table>
	{% for role in client.role_set.all %}
          <tr><td>
	      {{ role.title }}, {{ role.organisation }}
	  </td></tr>
	{% endfor %}
      </table>
    </td>
    <td><a href="mailto:{{ client.user.email }}">{{ client.user.email }}</a></td>
    <td>{{ client.office_phone }}</td>
    <td>
      {% tags_for_object client as tags %} 
      {% for tag in tags %}
        <a href="{% url crm_tagged_client tag_name=tag.name %}">{{ tag.name }}</a>
      {% endfor %}
    </td>
  </tr>
  {% endfor %}
</table>
{% else %}
  <p>No clients</p>
{% endif %}
